package com.hfplm.lhh.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;

import com.hfplm.hsdz.rac.stylesheet.PLGGFormRendering;
import com.teamcenter.rac.aif.AbstractAIFUIApplication;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCSession;

public class PLGGFormRenderingView extends AbstractHandler{
	private TCSession session;
	private AbstractAIFUIApplication app;
	TCComponent comp;

	@Override
	public Object execute(ExecutionEvent arg0) throws ExecutionException {
		// TODO Auto-generated method stub
		app = AIFUtility.getCurrentApplication();
		session = (TCSession) app.getSession();
		comp = (TCComponent) app.getTargetComponent();
		if(comp instanceof TCComponentForm && comp.getType().equals("HS_PLGG Form")) {
			new Thread(){
				public void run() {
					try {
						new PLGGFormRendering(comp, true);
					} catch (Exception e) {
						e.printStackTrace();
					}
				};
			}.start();
		}
	
		return null;
	}

}
